package com.lowang.test.thrift;

import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.server.TThreadPoolServer.Args;
import org.apache.thrift.transport.TServerSocket;

import com.lowang.test.thrift.service.IHelloThriftService;
import com.lowang.test.thrift.service.impl.HelloServiceImpl;

/**
 * Hello world!
 *
 */
public class App {
    public static void main(String[] args) {
        try {
            TServerSocket sc = new TServerSocket(6161);
            Factory factory = new TBinaryProtocol.Factory();
            TProcessor processor = new IHelloThriftService.Processor(new HelloServiceImpl());
            Args arg = new Args(sc);
            arg.processor(processor);
            arg.protocolFactory(factory);
            TServer server = new TThreadPoolServer(arg);
            server.serve();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
